# coding=utf-8
n=int(input())
for i in range(n):
    a=sorted(list(input().strip()))
    print(a[0],a[1],a[2])
